//
//  CommentTableViewCell.m
//  二级评论
//
//  Created by Andrew on 2018/1/22.
//  Copyright © 2018年 Andrew. All rights reserved.
//

#import "CommentTableViewCell.h"
#import "YMStringSize.h"

@interface CommentTableViewCell ()

/* 评论 */
@property (nonatomic, weak) UILabel *commentL;

@end

@implementation CommentTableViewCell

+ (instancetype)cellWithTableVie:(UITableView *)tableView
{
    static NSString *cellID = @"CommentTableViewCell";
    CommentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[CommentTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        /* 评论 */
        UILabel *commentL = [[UILabel alloc] init];
        commentL.font = LabelFontRegular(16);
        commentL.numberOfLines = 0;
        [self addSubview:commentL];
        self.commentL = commentL;
        
    }
    return self;
}

- (void)setCommentStr:(NSString *)commentStr
{
    _commentStr = commentStr;
    
    CGFloat w = SCREENWIDTH - 10 - 10 - 5; //左右边距
    CGFloat h = 5 + 5;//上下边距
    CGFloat commentH = [YMStringSize ym_sizeWithText:commentStr font:LabelFontRegular(16) maxW:w].height + h;
    self.commentL.frame = CGRectMake(10, 0, w, commentH);
    self.commentL.text = commentStr;
}

@end
